package idiet.service;

import idiet.bean.Customer;
import idiet.dao.hibernate.CustomerDao;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("customerService")
public class CustomerService {
	@Autowired
	CustomerDao customerDao;
	public Customer getCustomer(int customerId){
		return this.customerDao.getCustomerByCustomerId(customerId);
	}
	public List<Customer> getCustomers(String customerName){
		if(customerName==null){
			return this.customerDao.getCustomers();
		}else{
			return this.customerDao.getCustomersByCustomerName(customerName);
		}
	}
	public void createCustomer(Customer customer){
		this.customerDao.createCustomer(customer);
	}
	public List<Customer> getCustomers(String customerName,Timestamp lmTimestampStart,Timestamp lmTimestampEnd){
		if(customerName==null){
			return this.customerDao.getCustomers(lmTimestampStart, lmTimestampEnd);
		}else{
			return this.customerDao.getCustomers(customerName, lmTimestampStart, lmTimestampEnd);
		}
	}
}
